#include <AT89X52.h>
unsigned char a[16]={0x3F,0x06,0x66,0x07,0x80,0x5B,0x6D,0x7F,0x09,0x4F,0x7D,0x6F,0x52,0x2D,0x40,0x03};
void keyscan() 
{
int x,y,z;
unsigned char b,c;
P1=0x7F;
P2=0xF0;
b=P2;
if(b==0xF0)
  {}
     else if(b==0x70)
     {x=0;}
     else if(b==0xB0)
     {x=1;}
     else if(b==0xD0)
     {x=2;}
     else if(b==0xE0)
     {x=3;}
P2=0x0F;
c=P2;
if(c==0x0F)
  {}
    else if(c==0x07)
    {y=0;}
    else if(c==0x0B)
    {y=1;}
    else if(c==0x0D)
    {y=2;}
    else if(c==0x0E)
    {y=3;}
z=x+4*y;
P0=a[z];
}
void main()
{
while (1)
{
keyscan();
}
}